<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
</head>
<body>
	
<script>
function changeImage()
{
	element=document.getElementById('myimage')
	if (element.src.match("bulbon"))
	{
		element.src="pic_bulboff.gif";
	}
	else
	{
		element.src="pic_bulbon.gif";
	}
}
</script>
<img id="myimage" onclick="changeImage()" src="/images/pic_bulboff.gif" width="100" height="180">
<p>点击灯泡就可以打开或关闭这盏灯</p>
<script>
	function change2(){
		element = document.getElementById('myimage2')
	if(element.src.match('moon')){
		element.src = "sun.jpg";
	}
	else
	{
		element.src = "moon.jpg";
	}
	}
</script>
<img id = 'myimage2' onclick="change2()" src = "sun.jpg" width = "180" height = "180">
<p>点击图片切换</p>
</body>
</html>